package www.superbytecode.com.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-platform-builder
 * @Package: www.superbytecode.com.util
 * @ClassName: DateUtil
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2020/11/15 15:58
 * @Version: V1.0
 * @Copyright: 2020 www.super-bytecode.com Inc. All rights reserved.
 * @TODO: 注意, 本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
public class DateUtil {
    /**
     * @Description: [获取当前时间]
     * @Title: getServerStartDate
     * @Author: Lance Ting
     * @Date: 2020-06-25
     * @Param:
     * @Return: java.lang.String
     * @Throws
     */
    public static String getCurrentDateText() {
        Calendar calendar = Calendar.getInstance();
        return convertDate2FormatText(new Date(), "yyyy-MM-dd hh:mm:ss");
    }

    /**
     * @Description: [时间格式数据格式化指定类型]
     * @Title: convertDate2FormatText
     * @Author: Lance Ting
     * @Date: 2020-06-25
     * @Param: date  时间数据
     * @Param: formatType 格式化类型
     * @Return: java.lang.String
     * @Throws
     */
    public static String convertDate2FormatText(Date date, String formatType) {
        DateFormat dateFormat = setDateFormat(formatType);
        return dateFormat.format(date);
    }

    /**
     * @Description: [设置时间指定格式对象]
     * @Title: setDateFormat
     * @Author: Lance Ting
     * @Date: 2020-06-25
     * @Param: formatType
     * @Return: java.text.DateFormat
     * @Throws
     */
    public static DateFormat setDateFormat(String formatType) {
        return new SimpleDateFormat(formatType);
    }

    /**
     * @Description: [获取当前年份值]
     * @Title: getCurrentYear
     * @Author: Lance Ting
     * @Date: 2020-06-25
     * @Return: int
     * @Throws
     */
    public static int getCurrentYear() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.YEAR);
    }
}